package com.zy.explore.license.infrastructure.exception;

/**
 * description 基本业务异常，所有的业务异常
 *
 * @author 🇨🇳中国印🇨🇳
 * @date 2022年04月17日 02:36:49
 * @since 1.0.0
 */
public class BaseException extends RuntimeException implements StatusCode {

    protected Integer code;
    protected String message;

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        String message = super.getMessage();
        return message == null ? "服务器出错" : super.getMessage();
    }

    public BaseException(MessageCode mc) {
        this.code = mc.getCode();
        this.message = mc.getMessage();
    }

    public BaseException(int code) {
        this.code = code;
    }

    public BaseException(int code, String message) {
        super(message);
        this.message = message;
        this.code = code;
    }

    public BaseException(int code, Throwable cause) {
        super(cause);
        this.code = code;
    }

    public BaseException(int code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public BaseException(int code, String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.code = code;
    }
}
